<template>
  <div class="m-porducts-list">
    <div class="m-container">
      <!-- sku列表 -->
      <section class="sku-list">
        <a
          class="sku-item"
          v-for="item in skuList"
          :key="item.skuId"
          :href="`/m-products-detail/${item.skuId}`"
          :title="item.skuNameOfLang"
        >
          <el-image class="sku-img" fit="cover" :src="item.coverImage" lazy :alt="item.skuNameOfLang"></el-image>
          <div class="sku-title">{{ item.skuNameOfLang }}</div>
          <div class="sub-type-Name">{{ item.subTypeNameOfLang }}</div>
          <div class="sku-detail">
            <div class="specs-compare" v-for="specsItem in item.specsList" :key="specsItem.specsName">
              <p>{{ specsItem.specsNameOfLang }}</p>
              <p>{{ specsItem.specsValue }}</p>
            </div>
            <div class="view-detail">
              <span>{{ $t("learnMore") }}</span>
              <i class="arrow el-icon-arrow-right"></i>
            </div>
          </div>
        </a>
      </section>
    </div>
    <!-- WhatsApp -->
    <!-- <WhatsAppM v-if="locale == 'en-US'" /> -->
    <!-- 底部信息 -->
    <FooterM></FooterM>
  </div>
</template>

<script>
import { mapState } from "vuex"
export default {
  name: "M-porductsList",
  layout: "mobile",
  data() {
    return {}
  },
  head() {
    return {
      title: this.$i18n.t("headTitle"),
      meta: [
        {
          hid: "keywords",
          name: "keywords",
          content: this.$i18n.t("haeaKeyContent")
        },
        {
          hid: "description",
          name: "description",
          content: this.$i18n.t("haeaDecContent")
        }
      ]
    }
  },
  async asyncData({ app, params }) {
    let paramsRes = params.listParams.split("-")
    console.log("paramsRes", paramsRes)
    let bigTypeName = paramsRes[0]
    let subTypeName = paramsRes[1]
    let skuList = []
    try {
      let { data } = await app.$api.allCategory()
      data.map((item) => {
        if (item.bigTypeName == bigTypeName) {
          item.subCategoryVOList.map((subItem) => {
            if (subItem.subTypeName == subTypeName) {
              skuList = subItem.skuList
            }
          })
        }
      })
    } catch (error) {
      console.log(error)
    }
    return {
      skuList
    }
  },
  props: {},
  computed: { ...mapState(["locale"]) },
  async mounted() {
    this.getPoint()
  },
  methods: {
    async getPoint() {
      let params = await this.$optionPoint.sendUrl(window, navigator, document)
      this.$api.burySave({ ...params }).then((res) => {})
    }
  }
}
</script>

<style lang="scss" scoped>
.m-porducts-list {
  .sku-list {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-top: 290px;
    .sku-item {
      width: 860px;
      height: 100%;
      margin-bottom: 50px;
      .sku-img {
        width: 860px;
        height: 543px;
        display: block;
      }
      .sku-title {
        width: 860px;
        line-height: 82px;
        font-family: PingFangSC, PingFang SC;
        font-weight: 500;
        font-size: 72px;
        color: #333;
        text-align: center;
        margin-top: 40px;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
      }
      .sub-type-Name {
        font-family: PingFangSC, PingFang SC;
        font-weight: 500;
        font-size: 72px;
        color: #333;
        text-align: center;
        margin-top: 40px;
      }
      .sku-detail {
        width: 100%;
        height: 100%;
        background: #f6f7f9;
        margin-top: 40px;
        padding: 30px;
        box-sizing: border-box;
        .specs-compare {
          display: flex;
          align-items: center;
          justify-content: space-between;
          margin-bottom: 30px;
          p {
            font-family: PingFangSC, PingFang SC;
            font-weight: 400;
            font-size: 60px;
            line-height: 80px;
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
            &:nth-child(1) {
              color: #999;
            }
            &:nth-child(2) {
              color: #333;
            }
          }
        }
        .view-detail {
          display: flex;
          align-items: center;
          justify-content: right;
          padding: 20px 0;
          span {
            font-family: PingFangSC, PingFang SC;
            font-weight: 400;
            font-size: 60px;
            color: #999;
          }
          .arrow {
            font-size: 70px;
            color: #999;
          }
        }
      }
    }
  }
}
</style>
